require 'watir'
include Watir
require 'test/unit'
class TC_blogsFrontEnd < Test::Unit::TestCase
  	def test_16_ModifyBlogText_Blogs

    $ie.goto($UniVar)

#Create Blog
    $ie.goto($UniVar + '/controlpanel/BlogAdmin/sectionedit.aspx')
    $ie.wait()    
    $ie.text_field(:index, 1).set('watir blog')
    $ie.text_field(:index, 2).set('watirblog')
    $ie.text_field(:index, 3).set($ADMIN)
    $ie.link(:text, 'Save').click    

#Create Blog Post
    temp_var = "Now we try to change the body content of the post"
    $ie.goto($UniVar + '/ControlPanel/Blogs/posteditor.aspx?SelectedNavItem=NewPost')
    $ie.wait()
    $ie.text_field(:id, /ctl00_ctl00_TaskRegion_Editor1_PostSubject/).set('temporary')    
    $ie.ie.Document.parentWindow.execScript("tinyMCE.getInstanceById(tinyMCE.getEditorId('mce_editor_0')).execCommand('mceSetContent', false, '" + temp_var + "')")        
    $ie.link(:text, 'Publish').click

#test specifics
    $ie.goto($UniVar + '/ControlPanel/Blogs/AboutOptions.aspx')
    $ie.text_field(:id, /AboutTitle$/).clear
    $ie.text_field(:id, /AboutTitle$/).set('Change about watir blog title')    
    $ie.ie.Document.parentWindow.execScript("tinyMCE.getInstanceById(tinyMCE.getEditorId('mce_editor_0')).execCommand('mceSetContent', false, '" + temp_var + "')")            
    $ie.radio(:id, /ctl00_ctl00_TaskRegion_ynEnableAbout_0/).set
    $ie.link(:text, 'Save').click

    $ie.link(:text, 'Exit Control Panel and Return to Site').click
    $ie.link(:text, 'Blogs').click
    $ie.link(:text, 'temporary').click
    $ie.link(:text, 'About').click
    assert($ie.contains_text('Now we try to change the body content of the post'))
#/|\ 

#Delete Blog
        $ie.goto($UniVar + '/controlpanel/BlogAdmin/Blogs.aspx')
        $ie.wait()
        $ie.link(:text, 'Delete').click_no_wait
        hwnd = $ie.enabled_popup(20)
          if(hwnd)
            w = WinClicker.new
            w.clickWindowsButton_hwnd(hwnd, "OK")
          end     

	end
end